package org.neuedu.fly.web;

import org.neuedu.fly.entity.vo.ResponseEntity;
import org.neuedu.fly.service.PostService;
import org.neuedu.fly.service.UserService;

import javax.servlet.annotation.WebServlet;

@WebServlet("/management/*")
public class managementServlet extends BaseServlet{
    private UserService userService = new UserService();
    private UserServlet userServlet = new UserServlet();
    private PostService postService = new PostService();
    private postIndexServlet postIndexServlet = new postIndexServlet();
    public ResponseEntity userPage(){
        String pageIndex = request.getParameter("page");
        String pageSize = request.getParameter("limit");
        return userService.page(pageIndex,pageSize);
    }

    public ResponseEntity postPage() {
        int pageIndex = Integer.parseInt(request.getParameter("page"));
        int pageSize = Integer.parseInt(request.getParameter("limit"));
        return postService.page(pageIndex,pageSize);
    }

    public ResponseEntity userDel(){
        int uId = Integer.parseInt(request.getParameter("id"));
        return userService.del(uId);
    }

    public ResponseEntity postDel(){
        int postId = Integer.parseInt(request.getParameter("id"));
        return postService.delPostByPostId(postId);
    }

    public ResponseEntity userEdit(){
        return userServlet.edit();
    }
}
